package com.qfly.main.controller;

import com.qfly.main.common.bean.BaseController;
import com.qfly.main.common.bean.Result;
import com.qfly.main.model.entity.SysUser;
import com.qfly.main.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Wisdytech.cn
 * com.qfly.main.controller.UserController
 *
 * @author hailin.zhl
 * @date 2018/12/13
 */
@RestController
public class UserController extends BaseController{

    @Autowired
    private UserRepository userRepository;

    @RequestMapping("/addUser")
    public Result<Void> addUser() {
        SysUser user = SysUser.builder()
                .username("test1")
                .password("123456")
                .build();
        userRepository.save(user);
        return success();
    }

    @RequestMapping("/testException")
    public void testException() {

        throw new RuntimeException("test");
        //return empty();
    }
}
